# chicago-inequality-and-violence

Replication data and code for "Neighborhood Inequality and Violence in Chicago, 1965-2020" by Patrick Sharkey and Alisabeth Marsteller: https://lawreview.uchicago.edu/publication/neighborhood-inequality-and-violence-chicago-1965%E2%80%932020.

This archive contains subdirectories for the replication data ("data"), replication code ("R"), and the resulting figures that are presented in the paper ("figures").

The data provided for replication are cleaned and processed data from multiple sources (U.S. Census, American Community Survey, Chicago Data Portal, Gun Violence Archive, Illinois Criminal Justice Information Authority, and Opportunity Atlas). 

## Replication and Reproduction

The main script to be run is  **"R/01_Run_Analysis.R"**. This script runs all functions that process the data and replicate figures and tables from the paper. The processing steps can be re-run or they can be skipped and immediately run the functions *run_Chicago_analysis()* and *run_National_analysis()* since the clean data is provided.

*Note: You will need a census key for the 'tidycensus' package if you are replicating the processing of the National demographics data (process_demographics_Nation.R) which can be entered at the top of 01_Run_Analysis.R. Obtain a census key here: https://api.census.gov/data/key_signup.html.*


## Contents

### R/

The "R" folder contains the code to process the data and replicate the figures from the paper. There are three main subdirectories here:

1. **"helper_functions"**: contains multiple R scripts with functions used more than once throughout the analysis. All helper functions start with a ".", so if a function that starts with a period is embedded in the code, look in this folder for details. Helper functions that are specific to a single script or function are generally found at the bottom of the same script in which the function is located.
2. **"Chicago"**: contains all code relevant to the Chicago section of the analysis (demographics \& compounded disadvantage) with the exception of any helper functions. The Chicago homicide dataset is provided in its aggregated form, so there is no script to process it.
    - *Chicago_Analysis.R*: generates the Chicago figures.
    - *process_demographics_Chicago.R*: processes raw demographic files for Chicago and produces clean file.
    - *process_comp_disadv_Chicago.R*: processes police shootings at the tract level and male incarceration files for Chicago.
    - *Chicago_graphing_helpers.R*: helps to format Chicago data for plotting and producing tables. Only used in *Chicago_Analysis.R*.
3. **"Nation"**: contains all code relevant to the National Shootings section of the analysis (shootings \& compounded disadvantage) with the exception of any helper functions.
    - *National_Analysis.R*: generates the National figures.
    - *process_fatal_shootings_Nation.R*: processes fatal shootings by census tract for 100 cities and produces clean file.
    - *process_demographics_Nation.R*: processes raw demographic files for 100 cities.
    - *process_comp_disadv_Nation.R*: processes police shootings data by census tract and male incarceration data for 100 cities.
    - *Nation_graphing_helpers.R*: helps to format national data for plotting and producing tables. Only used in *National_Analysis.R*.
 
There are also 3 files that are in the "R" folder but are not in a subdirectory:

1. *01_Run_Analysis.R*: Main file that calls functions to process raw data and generate figures from paper.

2. *file_locations.R*: contains the information for a list object of file paths which is invoked throughout the code to locate raw and processed data files.

3. *process_city_geographies.R*: This only needs to be run a single time if the directory **./data/Nation/geography/** is empty. This script generates the shapefile of 2010 census tracts that exist within the census-place boundaries of all 100 cities. 
 
### figures/

The "figures" folder contains 2 subdirectories:
  
  1. **"Chicago"**: all figures from the Chicago section of the analysis.
  2. **"Nation"**: all figures from the National section of the analysis.
  
  
## Compile Figures

*ChicagoLawReview_Figures.Rmd* in the parent directory will compile all resulting figures into a .pdf file.

## References

- U.S. Census Bureau. Total Population, Race (Before Substitutions and Allocations), and Poverty Status for Families, 1970 on 2010 Geographies. Prepared by Social Explorer.
- U.S. Census Bureau. Total Population, Race By Spanish Origin Status, and Poverty Status In 1979 (short version), 1980 on 2010 Geographies. Prepared by Social Explorer.
- U.S. Census Bureau. Total Population, Hispanic Origin By Race, and Poverty Status in 1989 By Age Group, 1990 on 2010 Geographies. Prepared by Social Explorer.
- U.S. Census Bureau. Total Population, Hispanic or Latino by Race, and Poverty Status by Sex, 2000 on 2010 Geographies. Prepared by Social Explorer.
- U.S. Census Bureau. Total Population, and Hispanic Or Latino Origin By Race, 2010. Prepared by Social Explorer.
- American Community Survey. Total Population, and Poverty Status in the Past 12 Months by Sex by Age, 2006-2010. Prepared by Social Explorer.
- American Community Survey. Total Population, Hispanic or Latino by Race, and Poverty Status in the Past 12 Months by Sex, 2010-2014. Prepared by Social Explorer.
- American Community Survey. Total Population, Hispanic or Latino by Race, and Poverty Status in the Past 12 Months by Sex, 2015-2019. Prepared by Social Explorer.
- Gun Violence Archive. https://www.gunviolencearchive.org/.
- Chicago Data Portal. Crimes 2001-Present. https://data.cityofchicago.org/Public-Safety/Crimes-2001-to-Present/ijzp-q8t2.
- Illinois Criminal Justice Information Authority. Homicides in Chicago Dataset. https://www.icpsr.umich.edu/web/pages/NACJD/guides/hc.html#about.
- Chetty, Raj, John Friedman, Nathaniel Hendren, Maggie R. Jones, and Sonya Porter. Working Paper. “The Opportunity Atlas: Mapping the Childhood Roots of Social Mobility”. https://www.opportunityatlas.org/.


